using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FlexminAdmin.Forms
{
    public delegate void AdvanceDelegate(int step);
    public delegate void CloseDelegate();

    public partial class PluginCopyForm : Form
    {
        public PluginCopyForm()
        {
            InitializeComponent();
        }

        public void SetFileLength(int size)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new AdvanceDelegate(SetFileLength),
                            new object[] { size });
                return;
            }

            copyProgressBar.Minimum = 0;
            copyProgressBar.Maximum = size;
            copyProgressBar.Value = 0;
        }

        public void Advance(int step)
        {

            if (this.InvokeRequired)
            {
                this.Invoke(new AdvanceDelegate(Advance),
                            new object[] { step });
                return;
            }

            copyProgressBar.Step = step;
            copyProgressBar.PerformStep();
        }

        public void DoClose()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new CloseDelegate(DoClose));
                return;
            }

            Close();
        }
    }
}